package com.yale.elasticsearch.factory.factoryImpl;

import co.elastic.clients.elasticsearch._types.query_dsl.Query;
import co.elastic.clients.json.JsonData;
import com.yale.elasticsearch.factory.RangeQueryStrategy;

/**
 * @author :yale
 * @date : 2024/8/7
 */
public class GteLteRangeQuery implements RangeQueryStrategy {
    @Override
    public Query createRangeQuery(String startValue, String endValue, String field) {
        return Query.of(q -> q
                .range(r -> r
                        .field(field)
                        .gte(JsonData.fromJson(startValue))
                        .lte(JsonData.fromJson(endValue))
                )
        );
    }
}
